
//小写首字母转换
export function capitalizeFirstLetter(obj: { [key: string]: string | number }): { [key: string]: string | number } {
  const newObj: { [key: string]: string | number } = {};
  for (const key in obj) {
    const formattedKey = key.charAt(0).toUpperCase() + key.slice(1);
    newObj[formattedKey] = obj[key];
  }
  return newObj;
}


//时间转换
export function formatTime(time: string | number) {
  if (time === null) {
    return ''
  } else {
    const date = new Date(time)
    const y = date.getFullYear()
    let m: string | number = date.getMonth() + 1
    m = m < 10 ? `0${String(m)}` : m
    let d: string | number = date.getDate()
    d = d < 10 ? `0${String(d)}` : d
    let h: string | number = date.getHours()
    h = h < 10 ? `0${String(h)}` : h
    let minute: string | number = date.getMinutes()
    minute = minute < 10 ? `0${String(minute)}` : minute
    let second: string | number = date.getSeconds()
    second = second < 10 ? `0${String(second)}` : second
    return `${String(y)}-${String(m)}-${String(d)}   ${String(h)}:${String(
      minute
    )}:${String(second)}`
  }
}


